/*---------------------------------------------------------------------------*/
/*!				\file				Settings.c
				\date				march 2010
				\author				TNick

				\brief				Loading and saving settings
    
*/
/* ------------------------------------------------------------------------- */
/* ========================================================================= */
//
//
//
//
/*  INCLUDES    ------------------------------------------------------------ */
	#include	"Config.h"
	#include	<windows.h>
	#include	<Commctrl.h>
	
	#include	"main.h"
	#include	"Resources.h"
	
/*  INCLUDES    ============================================================ */
//
//
//
//
/*  DEFINITIONS    --------------------------------------------------------- */

/*  DEFINITIONS    ========================================================= */
//
//
//
//
/*  DATA    ---------------------------------------------------------------- */

/*  DATA    ================================================================ */
//
//
//
//
/*  FUNCTIONS    ----------------------------------------------------------- */


/* ------------------------------------------------------------------------- */
LRESULT CALLBACK WP_Div				(HWND hh, UINT mm, WPARAM ww, LPARAM ll)
{
    switch(mm)
    {
	case	WM_CREATE: {
		SETWLINK(hh, FALSE);
    break;}
    case	WM_LBUTTONDOWN: {
		SetCapture(hh);
		SETWLINK(hh, TRUE);
    break;}
	case	WM_LBUTTONUP: {
		ReleaseCapture();
		SETWLINK(hh, FALSE);
	break;}
	case	WM_MOUSEMOVE: {
		if (GETWLINK(hh) != FALSE)
		{
			SendMessage(GetParent(hh),WM_SEP_MOVING,GetDlgCtrlID(hh),0);
		}
	break;}
	default:
		return DefWindowProc(hh, mm, ww, ll);
	}
	return 0;
}
/* ========================================================================= */

/* ------------------------------------------------------------------------- */
void			GetOptions			(HWND hh)
{
	TCHAR	TxBf[256];
	memset(&TxBf,0,256);
	
	if (GetDlgItemText(hh, IDC_EDT_SHOW_CH, (TCHAR*)&TxBf, 255) != 1)
	{
		AppStgs.ShowSrg.Letter = 0;
	}
	else
	{
		AppStgs.ShowSrg.Letter = (char)TxBf[0];
		if (IsDlgButtonChecked(hh, IDC_CHK_SHOW_C) == BST_CHECKED) AppStgs.ShowSrg.Ctrl = 1;
		else AppStgs.ShowSrg.Ctrl = 0;
		if (IsDlgButtonChecked(hh, IDC_CHK_SHOW_A) == BST_CHECKED) AppStgs.ShowSrg.Alt = 1;
		else AppStgs.ShowSrg.Alt = 0;
		if (IsDlgButtonChecked(hh, IDC_CHK_SHOW_S) == BST_CHECKED) AppStgs.ShowSrg.Shift = 1;
		else AppStgs.ShowSrg.Shift = 0;
	}
	
	if (GetDlgItemText(hh, IDC_EDT_HIDE_CH, (TCHAR*)&TxBf, 255) != 1)
	{
		AppStgs.HideSrg.Letter = 0;
	}
	else
	{
		AppStgs.HideSrg.Letter = (char)TxBf[0];
		if (IsDlgButtonChecked(hh, IDC_CHK_HIDE_C) == BST_CHECKED) AppStgs.HideSrg.Ctrl = 1;
		else AppStgs.HideSrg.Ctrl = 0;
		if (IsDlgButtonChecked(hh, IDC_CHK_HIDE_A) == BST_CHECKED) AppStgs.HideSrg.Alt = 1;
		else AppStgs.HideSrg.Alt = 0;
		if (IsDlgButtonChecked(hh, IDC_CHK_HIDE_S) == BST_CHECKED) AppStgs.HideSrg.Shift = 1;
		else AppStgs.HideSrg.Shift = 0;
	}
	
	
	
	if (IsDlgButtonChecked(hh, IDC_CHK_GSHOW_TL) == BST_CHECKED) AppStgs.ShowGest[0] = 1;
	else AppStgs.ShowGest[0] = 0;
	if (IsDlgButtonChecked(hh, IDC_CHK_GSHOW_TR) == BST_CHECKED) AppStgs.ShowGest[1] = 1;
	else AppStgs.ShowGest[1] = 0;
	if (IsDlgButtonChecked(hh, IDC_CHK_GSHOW_BL) == BST_CHECKED) AppStgs.ShowGest[2] = 1;
	else AppStgs.ShowGest[2] = 0;
	if (IsDlgButtonChecked(hh, IDC_CHK_GSHOW_BR) == BST_CHECKED) AppStgs.ShowGest[3] = 1;
	else AppStgs.ShowGest[3] = 0;
	
	if (IsDlgButtonChecked(hh, IDC_CHK_GHIDE_TL) == BST_CHECKED) AppStgs.HideGest[0] = 1;
	else AppStgs.HideGest[0] = 0;
	if (IsDlgButtonChecked(hh, IDC_CHK_GHIDE_TR) == BST_CHECKED) AppStgs.HideGest[1] = 1;
	else AppStgs.HideGest[1] = 0;
	if (IsDlgButtonChecked(hh, IDC_CHK_GHIDE_BL) == BST_CHECKED) AppStgs.HideGest[2] = 1;
	else AppStgs.HideGest[2] = 0;
	if (IsDlgButtonChecked(hh, IDC_CHK_GHIDE_BR) == BST_CHECKED) AppStgs.HideGest[3] = 1;
	else AppStgs.HideGest[3] = 0;
	
	if (IsDlgButtonChecked(hh, IDC_CHK_SHOW) == BST_CHECKED) AppStgs.Flags |= APPFL_SHOWGEST;
	else AppStgs.Flags &= ~APPFL_SHOWGEST;
	if (IsDlgButtonChecked(hh, IDC_CHK_GHIDE) == BST_CHECKED) AppStgs.Flags |= APPFL_HIDEGEST;
	else AppStgs.Flags &= ~APPFL_HIDEGEST;
	AppStgs.EpocsToWait = GetDlgItemInt(hh, IDC_EDT_GST_TO,(BOOL*)&TxBf,FALSE);
	
	if (AppStgs.Flags & APPFL_SHOWGEST)
	{
		if (AppStgs.ShowGest[0] + AppStgs.ShowGest[1] + AppStgs.ShowGest[2] + AppStgs.ShowGest[3] != 2)
		{
			MessageBox(hh,
				ERR_GEST,
				ERR_TEXT,
				MB_OK | MB_ICONERROR);
			return;
		}
	}
		
	if (AppStgs.Flags & APPFL_HIDEGEST)
	{
		if (AppStgs.HideGest[0] + AppStgs.HideGest[1] + AppStgs.HideGest[2] + AppStgs.HideGest[3] != 2)
		{
			MessageBox(hh,
				ERR_GEST,
				ERR_TEXT,
				MB_OK | MB_ICONERROR);
			return;
		}
	}
	
	if (IsDlgButtonChecked(hh, IDC_CHK_WFILT_NAME) == BST_CHECKED) AppStgs.Flags |= APPFL_FLTR_NAME;
	else AppStgs.Flags &= ~APPFL_FLTR_NAME;
	if (IsDlgButtonChecked(hh, IDC_CHK_WFILT_HID) == BST_CHECKED) AppStgs.Flags |= APPFL_FLTR_HID;
	else AppStgs.Flags &= ~APPFL_FLTR_HID;
	if (IsDlgButtonChecked(hh, IDC_CHK_WFILT_ALTT) == BST_CHECKED) AppStgs.Flags |= APPFL_FLTR_ALTT;
	else AppStgs.Flags &= ~APPFL_FLTR_ALTT;
	if (IsDlgButtonChecked(hh, IDC_CHK_WFILT_ICON) == BST_CHECKED) AppStgs.Flags |= APPFL_FLTR_ICN;
	else AppStgs.Flags &= ~APPFL_FLTR_ICN;
	if (IsDlgButtonChecked(hh, IDC_CHK_WFILT_PARENT) == BST_CHECKED) AppStgs.Flags |= APPFL_FLTR_PRNT;
	else AppStgs.Flags &= ~APPFL_FLTR_PRNT;
	
	
	if (IsDlgButtonChecked(hh, IDC_CHK_STARTHD) == BST_CHECKED) AppStgs.Flags |= APPFL_STARTHD;
	else AppStgs.Flags &= ~APPFL_STARTHD;
	if (IsDlgButtonChecked(hh, IDC_CHK_APPHD) == BST_CHECKED) AppStgs.Flags |= APPFL_HIDEME;
	else AppStgs.Flags &= ~APPFL_HIDEME;
	if (IsDlgButtonChecked(hh, IDC_CHK_APPTOP) == BST_CHECKED)
	{
		AppStgs.Flags |= APPFL_ONTOP;
		SetWindowPos(hwMain,HWND_TOPMOST,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE);
	}
	else
	{
		AppStgs.Flags &= ~APPFL_ONTOP;
		SetWindowPos(hwMain,HWND_NOTOPMOST,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE);
	}
	

	DestroyWindow(hh);
}
/* ========================================================================= */

/* ------------------------------------------------------------------------- */
void			ShowOptions			(HWND hh)
{
	char	TxBf[256];
	
	memset(&TxBf,0,256);
	SendMessage(GetDlgItem(hh,IDC_EDT_SHOW_CH),EM_SETLIMITTEXT,1,0);
	SendMessage(GetDlgItem(hh,IDC_EDT_HIDE_CH),EM_SETLIMITTEXT,1,0);
	
	TxBf[0] = AppStgs.ShowSrg.Letter;
	TxBf[1] = 0;
	SetDlgItemText(hh, IDC_EDT_SHOW_CH, (TCHAR*)&TxBf);
	if (AppStgs.ShowSrg.Ctrl == 0) CheckDlgButton(hh,IDC_CHK_SHOW_C,BST_UNCHECKED);
	else CheckDlgButton(hh,IDC_CHK_SHOW_C,BST_CHECKED);
	if (AppStgs.ShowSrg.Alt == 0) CheckDlgButton(hh,IDC_CHK_SHOW_A,BST_UNCHECKED);
	else CheckDlgButton(hh,IDC_CHK_SHOW_A,BST_CHECKED);
	if (AppStgs.ShowSrg.Shift == 0) CheckDlgButton(hh,IDC_CHK_SHOW_S,BST_UNCHECKED);
	else CheckDlgButton(hh,IDC_CHK_SHOW_S,BST_CHECKED);
	
	TxBf[0] = AppStgs.HideSrg.Letter;
	TxBf[1] = 0;
	SetDlgItemText(hh, IDC_EDT_HIDE_CH, (TCHAR*)&TxBf);
	if (AppStgs.HideSrg.Ctrl == 0) CheckDlgButton(hh,IDC_CHK_HIDE_C,BST_UNCHECKED);
	else CheckDlgButton(hh,IDC_CHK_HIDE_C,BST_CHECKED);
	if (AppStgs.HideSrg.Alt == 0) CheckDlgButton(hh,IDC_CHK_HIDE_A,BST_UNCHECKED);
	else CheckDlgButton(hh,IDC_CHK_HIDE_A,BST_CHECKED);
	if (AppStgs.HideSrg.Shift == 0) CheckDlgButton(hh,IDC_CHK_HIDE_S,BST_UNCHECKED);
	else CheckDlgButton(hh,IDC_CHK_HIDE_S,BST_CHECKED);
	
	if (AppStgs.ShowGest[0] == 0) CheckDlgButton(hh,IDC_CHK_GSHOW_TL,BST_UNCHECKED);
	else CheckDlgButton(hh,IDC_CHK_GSHOW_TL,BST_CHECKED);
	if (AppStgs.ShowGest[1] == 0) CheckDlgButton(hh,IDC_CHK_GSHOW_TR,BST_UNCHECKED);
	else CheckDlgButton(hh,IDC_CHK_GSHOW_TR,BST_CHECKED);
	if (AppStgs.ShowGest[2] == 0) CheckDlgButton(hh,IDC_CHK_GSHOW_BL,BST_UNCHECKED);
	else CheckDlgButton(hh,IDC_CHK_GSHOW_BL,BST_CHECKED);
	if (AppStgs.ShowGest[3] == 0) CheckDlgButton(hh,IDC_CHK_GSHOW_BR,BST_UNCHECKED);
	else CheckDlgButton(hh,IDC_CHK_GSHOW_BR,BST_CHECKED);
	
	if (AppStgs.HideGest[0] == 0) CheckDlgButton(hh,IDC_CHK_GHIDE_TL,BST_UNCHECKED);
	else CheckDlgButton(hh,IDC_CHK_GHIDE_TL,BST_CHECKED);
	if (AppStgs.HideGest[1] == 0) CheckDlgButton(hh,IDC_CHK_GHIDE_TR,BST_UNCHECKED);
	else CheckDlgButton(hh,IDC_CHK_GHIDE_TR,BST_CHECKED);
	if (AppStgs.HideGest[2] == 0) CheckDlgButton(hh,IDC_CHK_GHIDE_BL,BST_UNCHECKED);
	else CheckDlgButton(hh,IDC_CHK_GHIDE_BL,BST_CHECKED);
	if (AppStgs.HideGest[3] == 0) CheckDlgButton(hh,IDC_CHK_GHIDE_BR,BST_UNCHECKED);
	else CheckDlgButton(hh,IDC_CHK_GHIDE_BR,BST_CHECKED);
	SetDlgItemInt(hh,IDC_EDT_GST_TO,AppStgs.EpocsToWait,FALSE);
	
	if (AppStgs.Flags & APPFL_SHOWGEST) CheckDlgButton(hh,IDC_CHK_SHOW,BST_CHECKED);
	else CheckDlgButton(hh,IDC_CHK_SHOW,BST_UNCHECKED);
	if (AppStgs.Flags & APPFL_HIDEGEST) CheckDlgButton(hh,IDC_CHK_GHIDE,BST_CHECKED);
	else CheckDlgButton(hh,IDC_CHK_GHIDE,BST_UNCHECKED);
	
	if (AppStgs.Flags & APPFL_FLTR_NAME) CheckDlgButton(hh,IDC_CHK_WFILT_NAME,BST_CHECKED);
	else CheckDlgButton(hh,IDC_CHK_WFILT_NAME,BST_UNCHECKED);
	if (AppStgs.Flags & APPFL_FLTR_HID) CheckDlgButton(hh,IDC_CHK_WFILT_HID,BST_CHECKED);
	else CheckDlgButton(hh,IDC_CHK_WFILT_HID,BST_UNCHECKED);
	if (AppStgs.Flags & APPFL_FLTR_ALTT) CheckDlgButton(hh,IDC_CHK_WFILT_ALTT,BST_CHECKED);
	else CheckDlgButton(hh,IDC_CHK_WFILT_ALTT,BST_UNCHECKED);
	if (AppStgs.Flags & APPFL_FLTR_ICN) CheckDlgButton(hh,IDC_CHK_WFILT_ICON,BST_CHECKED);
	else CheckDlgButton(hh,IDC_CHK_WFILT_ICON,BST_UNCHECKED);
	if (AppStgs.Flags & APPFL_FLTR_PRNT) CheckDlgButton(hh,IDC_CHK_WFILT_PARENT,BST_CHECKED);
	else CheckDlgButton(hh,IDC_CHK_WFILT_PARENT,BST_UNCHECKED);
	
	if (AppStgs.Flags & APPFL_STARTHD) CheckDlgButton(hh,IDC_CHK_STARTHD,BST_CHECKED);
	else CheckDlgButton(hh,IDC_CHK_STARTHD,BST_UNCHECKED);
	if (AppStgs.Flags & APPFL_HIDEME) CheckDlgButton(hh,IDC_CHK_APPHD,BST_CHECKED);
	else CheckDlgButton(hh,IDC_CHK_APPHD,BST_UNCHECKED);
	if (AppStgs.Flags & APPFL_ONTOP) CheckDlgButton(hh,IDC_CHK_APPTOP,BST_CHECKED);
	else CheckDlgButton(hh,IDC_CHK_APPTOP,BST_UNCHECKED);
	
}
/* ========================================================================= */


/* ------------------------------------------------------------------------- */
LRESULT CALLBACK Win_Proc_Opt		(HWND hh, UINT mm, WPARAM ww, LPARAM ll)
{
	switch (mm)
	{
		case WM_CLOSE:{
			hWOpts = NULL;
			DestroyWindow(hh);
		break;}
		case WM_INITDIALOG:{
			ShowOptions(hh);
		break;}
		
		case WM_COMMAND:{
			switch	(LOWORD(ww))
			{
			case	IDC_OK:{
				GetOptions(hh);
			break;}
			case	IDC_CANCEL:{
				DestroyWindow(hh);
			break;}
			}
		break;}
	default:
		return 0;
	}
	return 0;
}
/* ========================================================================= */


/* ------------------------------------------------------------------------- */
__inline 	void	WP_Main_Create		(HWND hh)
{
	
	RECT		r1;
	LVCOLUMN	column;
	unsigned	i;
	#ifdef	BBLANGUAGE_ROMANIAN
		TCHAR*		RgCols[LISTCOLS_CNT] = {TEXT("Nume"),TEXT("Clasa")};
	#else
		TCHAR*		RgCols[LISTCOLS_CNT] = {TEXT("Name"),TEXT("Class")};
	#endif
	
	GetClientRect(hwMain, &r1);
	
	CreateWindowEx (	
		   0, CALSS_DIV,NULL,
		   (WS_VISIBLE | WS_CHILD),
		   AppStgs.Width_Left, 
		   0, 
		   SEP_SIZE, r1.bottom,
		   hh,
		   (HMENU)ID_MAIN_DV,
		   hInstance,
		   NULL
		   );
    
	hW_Ls_L = CreateWindowEx (
		   0, WC_LISTVIEW, NULL,
		   (WS_VISIBLE | WS_CHILD | WS_BORDER |
		   LVS_REPORT | LVS_SHAREIMAGELISTS),
		   0, 
		   0, 
		   AppStgs.Width_Left, 
		   r1.bottom,
		   hh, (HMENU)ID_MAIN_LST_L, hInstance, NULL);
	SendMessage(hW_Ls_L,WM_SETFONT,(WPARAM)hF_Gen,0);
	SendMessage(hW_Ls_L,LVM_SETIMAGELIST,(WPARAM)LVSIL_SMALL,(LPARAM)hImLst);
	SendMessage(hW_Ls_L,LVM_SETIMAGELIST,(WPARAM)LVSIL_NORMAL,(LPARAM)hImLst);
	ListView_SetExtendedListViewStyle(hW_Ls_L, 
				LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES | LVS_EX_CHECKBOXES);
    
	column.mask = LVCF_FMT | LVCF_TEXT | LVCF_WIDTH;
	column.fmt = LVCFMT_LEFT;
	i = 0;
	while (i < LISTCOLS_CNT)
	{
		column.cx       = AppStgs.LsL_ColW[i];
		column.pszText  = RgCols[i];
		column.iSubItem = i;
		ListView_InsertColumn(hW_Ls_L,i,&column);
		i++;
	}
	
	hW_Ls_R = CreateWindowEx (
		   0, WC_LISTVIEW, NULL,
		   (WS_VISIBLE | WS_CHILD | WS_BORDER |
		   LVS_REPORT | LVS_SHAREIMAGELISTS),
		   AppStgs.Width_Left+SEP_SIZE, 
		   0, 
		   r1.right-AppStgs.Width_Left-SEP_SIZE, 
		   r1.bottom,
		   hh, (HMENU)ID_MAIN_LST_R, hInstance, NULL);
	SendMessage(hW_Ls_R,WM_SETFONT,(WPARAM)hF_Gen,0);
	SendMessage(hW_Ls_R,LVM_SETIMAGELIST,(WPARAM)LVSIL_SMALL,(LPARAM)hImLst);
	SendMessage(hW_Ls_R,LVM_SETIMAGELIST,(WPARAM)LVSIL_NORMAL,(LPARAM)hImLst);
	ListView_SetExtendedListViewStyle(hW_Ls_R, 
				LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES | LVS_EX_CHECKBOXES);
    
	column.mask = LVCF_FMT | LVCF_TEXT | LVCF_WIDTH;
	column.fmt = LVCFMT_LEFT;
	i = 0;
	while (i < LISTCOLS_CNT)
	{
		column.cx       = AppStgs.LsR_ColW[i];
		column.pszText  = RgCols[i];
		column.iSubItem = i;
		ListView_InsertColumn(hW_Ls_R,i,&column);
		i++;
	}
	
	RefreshVisList();
}
/* ========================================================================= */


/* ------------------------------------------------------------------------- */
__inline void		WP_Main_Close		(void)
{
	unsigned icnt = ListView_GetItemCount(hW_Ls_R);
	unsigned i = 0;
	
	SaveSettings(&AppStgs);
	while (i < icnt)
	{
		ListView_SetCheckState(hW_Ls_R, i, TRUE);
		i++;
	}
	Do_UnHideSelected();
	DestroyWindow(hwMain);
}
/* ========================================================================= */


/* ------------------------------------------------------------------------- */
__inline void		WP_Main_Size		(HWND hh)
{
	RECT	r1;
	HWND	hw;
	WINDOWPLACEMENT	pl;
	
	
	GetWindowPlacement(hh,&pl);
	if (pl.showCmd == SW_SHOWMINIMIZED) return;
	
	GetClientRect(hh, &r1);
	if (AppStgs.Width_Left > r1.right - MIN_WIDTH_MAIN) 
		AppStgs.Width_Left = r1.right - MIN_WIDTH_MAIN;
	
	hw = GetDlgItem(hh,ID_MAIN_LST_L);
	SetWindowPos(hw,HWND_TOP,0,0,AppStgs.Width_Left,r1.bottom,
			SWP_NOMOVE | SWP_NOOWNERZORDER | SWP_NOZORDER);
	hw = GetDlgItem(hh,ID_MAIN_DV);
	SetWindowPos(hw,HWND_TOP,AppStgs.Width_Left,0,SEP_SIZE,r1.bottom,
			SWP_NOOWNERZORDER | SWP_NOZORDER);
	hw = GetDlgItem(hh,ID_MAIN_LST_R);
	SetWindowPos(hw,HWND_TOP,
			AppStgs.Width_Left+SEP_SIZE,0,
			r1.right-AppStgs.Width_Left-SEP_SIZE,r1.bottom,
			SWP_NOOWNERZORDER | SWP_NOZORDER);
}
/* ========================================================================= */


/* ------------------------------------------------------------------------- */
__inline void		WP_Main_MoveSep		(void)
{
	POINT	pt;
	RECT	wRct;
	
	GetCursorPos(&pt);
	GetClientRect(hwMain,&wRct);
	ScreenToClient(hwMain,&pt);
	AppStgs.Width_Left = pt.x - (SEP_SIZE/2);
	if (AppStgs.Width_Left < MIN_WIDTH_MAIN) 
		AppStgs.Width_Left = MIN_WIDTH_MAIN;
	else if (AppStgs.Width_Left > wRct.right - MIN_WIDTH_MAIN) 
		AppStgs.Width_Left = wRct.right - MIN_WIDTH_MAIN;
	WP_Main_Size(hwMain);
	
}
/* ========================================================================= */


/* ------------------------------------------------------------------------- */
__inline void		WP_Main_Lst2Click	(NMITEMACTIVATE* pA)
{
	char			TxBf[256*sizeof(TCHAR)];
	LVITEM			it;
	unsigned		i;

	memset(&it,0,sizeof(LVITEM));
	memset(&TxBf,0,256);
	if (pA->iItem == -1) return;
	
	it.mask = LVIF_IMAGE | LVIF_PARAM | LVIF_TEXT;
	it.iItem = pA->iItem;
	it.iSubItem = 0;
	it.pszText = (TCHAR*)&TxBf;
	it.cchTextMax = 255;
	ListView_GetItem(pA->hdr.hwndFrom, &it);
	if (IsWindow((HWND)it.lParam) == FALSE)
	{
		MessageBox(hwMain,ERR_MISSINGWIN,ERR_TEXT,MB_OK | MB_APPLMODAL);
		ListView_DeleteItem(pA->hdr.hwndFrom,pA->iItem);
		return;
	}

	if (pA->hdr.idFrom == ID_MAIN_LST_L)
	{
		i = ListView_InsertItem(hW_Ls_R, &it);
		ShowWindow((HWND)it.lParam,SW_HIDE);
		ListView_GetItemText(hW_Ls_L,it.iItem,1,(TCHAR*)&TxBf,254);
		ListView_SetItemText(hW_Ls_R,i,1,(TCHAR*)&TxBf);
	}
	else
	{
		i = ListView_InsertItem(hW_Ls_L, &it);
		ShowWindow((HWND)it.lParam,SW_SHOW);
		ListView_GetItemText(hW_Ls_R,it.iItem,1,(TCHAR*)&TxBf,255);
		ListView_SetItemText(hW_Ls_L,i,1,(TCHAR*)&TxBf);
	}
	ListView_DeleteItem(pA->hdr.hwndFrom,pA->iItem);


}
/* ========================================================================= */


/* ------------------------------------------------------------------------- */
LRESULT CALLBACK	WP_Main			
					(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	switch (message)                  /* handle the messages */
    {
	case	WM_TIMER:{
		Epcs--;
		if (Epcs == 0)
		{
			GestureStart = GST_ROW_INVALID;
			KillTimer(hwMain, ID_TIMER_GESTURE);
			gTimer = 0;
		}
	break;}
	case	WM_SEP_MOVING:{
		WP_Main_MoveSep();
	break;}
	case	WM_NOTIFY:{
		switch	(((NMHDR*)lParam)->code)
		{
		case	NM_DBLCLK   :{
			WP_Main_Lst2Click((NMITEMACTIVATE*)lParam);
		break;}
		}
	break;}
    case WM_COMMAND:{
		switch	(LOWORD(wParam))
		{
		case	IDM_F_EXIT:			{
			SendMessage(hwMain,WM_CLOSE,0,0);
		break;}
		case	IDM_H_ABOUT:		{
			MessageBox(hwMain,ABOUT_TEXT,
			#ifdef	BBLANGUAGE_ROMANIAN
				TEXT("Despre BillyBoy ...")
			#else
				TEXT("About BillyBoy")
			#endif
			,MB_OK | MB_ICONINFORMATION);
		break;}
		case	IDM_A_HIDE:			{ 
			Do_HideSelected();
		break;}
		case	IDM_A_SHOW:			{
			Do_UnHideSelected();
		break;}
		case	IDM_A_SCAN:			{
			RefreshVisList();
		break;}
		case	IDM_A_OPT:			{
			hWOpts = CreateDialogParam(hInstance,
				MAKEINTRESOURCE(IDD_DLG_OPT), 
				NULL,(DLGPROC)Win_Proc_Opt,0);
		break;}
		}
    break;}
    case WM_SIZE:
		WP_Main_Size(hwnd);
        break;
    case WM_CREATE:
		WP_Main_Create(hwnd);
		break;
    case WM_CLOSE:
		WP_Main_Close();
		break;
    case WM_DESTROY:
        PostQuitMessage (0);       /* send a WM_QUIT to the message queue */
        break;
    default:                      /* for messages that we don't deal with */
		return DefWindowProc (hwnd, message, wParam, lParam);
    }
    return 0;

}
/* ========================================================================= */




/*  FUNCTIONS    =========================================================== */
//
//
//
//
/* ------------------------------------------------------------------------- */
/* ========================================================================= */
